package com.ityu.mapper;

import com.ityu.pojo.Emp;
import com.ityu.pojo.pagePojo.EmpPage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmpMapper {


    /**
     * 添加员工
     *
     * @param emp
     */
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    @Insert("insert into emp (username, password, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void addEmp(Emp emp);

    /**
     * 分页查询员工
     *
     * @param empPage
     * @return
     */
    List<Emp> pageListEmp(EmpPage empPage);

    /**
     * 批量删除员工
     *
     * @param ids
     */
    void deleteEmps(List<Integer> ids);

    /**
     * 根据id查询员工
     *
     * @param id
     * @return
     */
    Emp getEmpById(Integer id);

    /**
     * 修改员工
     *
     * @param emp
     */
    void updateEmp(Emp emp);

    /**
     * 查询所有员工
     *
     * @return
     */
    List<Emp> listEmp();

    /**
     * 根据用户名查询员工
     *
     * @param emp
     * @return
     */
    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getByUsername(Emp emp);
}
